import time

from selenium import webdriver

driver = webdriver.Chrome()

def do_snapshot(func):
    def wrapper(*args, **kwargs):

        try:
            func(*args, **kwargs)
        except:
            now_time = time.strftime('%Y_%m_%d_%H_%M_%S')
            driver.get_screenshot_as_file(f'{now_time}.jpg')

    return wrapper